import java.util.ArrayList;
import java.util.Iterator;




public class Main {


	public static void main(String[] args) {
		Monitor monitor = new Monitor(1,2);
		ArrayList<String> lista= new ArrayList<String>();
		Hilo1 r1 = new Hilo1(monitor,"Hilo1",lista);
		Thread h1 = new Thread(r1);
		h1.start();
		Hilo2 r2 = new Hilo2(monitor,"Hilo2",lista);
		Thread h2 = new Thread(r2);
		h2.start();
		try {
			h1.join();
			h2.join();
		} catch (InterruptedException e) {System.out.println("Programa terminado incorrectamente");}
		
		System.out.println("hilos terminados correctamente");
		Iterator it = (Iterator) lista.iterator();
		while(it.hasNext())
			System.out.println(it.next()+",");
	}

}
